import { Company } from "src/modules/company/company.entity";
import {
  BeforeInsert,
  Column,
  Entity,
  ManyToOne,
  PrimaryGeneratedColumn,
} from "typeorm";

@Entity()
export class Statistic {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @ManyToOne(() => Company, (company) => company.statistics, {
    nullable: false,
  })
  company: Company;

  @Column()
  date: Date;

  @Column("int", { default: 0 })
  order: number;

  @Column("int", { default: 0 })
  delivery: number;

  @BeforeInsert()
  updateDates() {
    this.date = new Date(new Date().toLocaleDateString());
  }
}
